package com.vimi8.ebb.auth.model;


import java.io.Serializable;


/**
 * 地址代码模型
 * Created by think on 2016/7/7.
 */

public class GeoCodings implements Serializable {
    /**
     * id
     */

    private String id;
    /**
     * 地址名字
     */

    private String geoName;
    /**
     *区域
     */

    private  int regionLever;
    /**
     * 省
     */

    private int prov;
    /**
     * 市区
     */

    private int city;
    /**
     * 区/县
     */

    private int county;
    /**
     * 镇/乡
     */

    private int village;
    /**
     * 村
     */

    private int burg;

    public GeoCodings() {
    }

    public GeoCodings(String id, String geoName, int regionLever, int prov, int city, int county, int village, int burg) {
        this.id = id;
        this.geoName = geoName;
        this.regionLever = regionLever;
        this.prov = prov;
        this.city = city;
        this.county = county;
        this.village = village;
        this.burg = burg;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getGeoName() {
        return geoName;
    }

    public void setGeoName(String geoName) {
        this.geoName = geoName;
    }

    public int getRegionLever() {
        return regionLever;
    }

    public void setRegionLever(int regionLever) {
        this.regionLever = regionLever;
    }

    public int getProv() {
        return prov;
    }

    public void setProv(int prov) {
        this.prov = prov;
    }

    public int getCity() {
        return city;
    }

    public void setCity(int city) {
        this.city = city;
    }

    public int getCounty() {
        return county;
    }

    public void setCounty(int county) {
        this.county = county;
    }

    public int getVillage() {
        return village;
    }

    public void setVillage(int village) {
        this.village = village;
    }

    public int getBurg() {
        return burg;
    }

    public void setBurg(int burg) {
        this.burg = burg;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GeoCodings that = (GeoCodings) o;

        if (regionLever != that.regionLever) return false;
        if (prov != that.prov) return false;
        if (city != that.city) return false;
        if (county != that.county) return false;
        if (village != that.village) return false;
        if (burg != that.burg) return false;
        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        return geoName != null ? geoName.equals(that.geoName) : that.geoName == null;

    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (geoName != null ? geoName.hashCode() : 0);
        result = 31 * result + regionLever;
        result = 31 * result + prov;
        result = 31 * result + city;
        result = 31 * result + county;
        result = 31 * result + village;
        result = 31 * result + burg;
        return result;
    }

    @Override
    public String toString() {
        return "GeoCodings{" +
                "id='" + id + '\'' +
                ", geoName='" + geoName + '\'' +
                ", regionLever=" + regionLever +
                ", prov=" + prov +
                ", city=" + city +
                ", county=" + county +
                ", village=" + village +
                ", burg=" + burg +
                '}';
    }

    /**
     * 返回该区划的下一级id值
     * @return
     */
    public long Next() {
        if (this.burg != 0) return Long.parseLong(this.id) + 1;
        if (this.village > 0) return Long.parseLong(this.id) + (long)Math.pow(10, 3);
        if (this.county > 0) return  Long.parseLong(this.id) + (long)Math.pow(10, 6);
        if (this.city > 0) return Long.parseLong(this.id) + (long)Math.pow(10, 8);
        return Long.parseLong(this.id) + (long)Math.pow(10, 10);
    }
}
